#include<iostream>
#include<vector>
#include<unordered_map>
using namespace std;

class Solution {
public:
    bool canConstruct(string ransomNote, string magazine) {
        unordered_map<char, int> hashRansomNote;
        unordered_map<char, int> hashMagazine;
        for (auto& e : ransomNote) {
            hashRansomNote[e]++;
        }
        for (auto& e : magazine) {
            hashMagazine[e]++;
        }
        for (auto& e : ransomNote) {
            if (hashRansomNote[e] > hashMagazine[e]) {
                return false;
            }
        }
        return true;
    }
};
